const doc = document
var cache = {}

export default {
    save(path) {
        cache[path] = doc.documentElement.scrollTop || doc.body.scrollTop
    },
    get() {
        const path = this.$route.path
        this.$nextTick(function () {
            doc.documentElement.scrollTop = doc.body.scrollTop = cache[path] || 0
        })
    },
    goTop() {
        this.$nextTick(function () {
            doc.documentElement.scrollTop = doc.body.scrollTop = 0
        })
    }
}